<?php

/**
 * This is the model class for table "{{admin}}".
 *
 * The followings are the available columns in table '{{admin}}':
 * @property integer $a_id
 * @property string $a_username
 * @property string $a_password
 * @property string $a_name
 * @property integer $a_loginnum
 * @property string $a_tel
 * @property string $a_phone
 * @property string $a_email
 * @property string $a_adderss
 * @property string $a_webset
 * @property integer $a_isdel
 */
class Admin extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{admin}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('a_username, a_password', 'required'),
			array('a_loginnum, a_isdel', 'numerical', 'integerOnly'=>true),
			array('a_username', 'length', 'max'=>30),
			array('a_password, a_tel, a_phone', 'length', 'max'=>100),
			array('a_name', 'length', 'max'=>50),
			array('a_email', 'length', 'max'=>200),
			array('a_adderss', 'length', 'max'=>400),
			array('a_webset', 'length', 'max'=>300),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('a_id, a_username, a_password, a_name, a_loginnum, a_tel, a_phone, a_email, a_adderss, a_webset, a_isdel', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'a_id' => 'A',
			'a_username' => 'A Username',
			'a_password' => 'A Password',
			'a_name' => 'A Name',
			'a_loginnum' => 'A Loginnum',
			'a_tel' => 'A Tel',
			'a_phone' => 'A Phone',
			'a_email' => 'A Email',
			'a_adderss' => 'A Adderss',
			'a_webset' => 'A Webset',
			'a_isdel' => 'A Isdel',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('a_id',$this->a_id);
		$criteria->compare('a_username',$this->a_username,true);
		$criteria->compare('a_password',$this->a_password,true);
		$criteria->compare('a_name',$this->a_name,true);
		$criteria->compare('a_loginnum',$this->a_loginnum);
		$criteria->compare('a_tel',$this->a_tel,true);
		$criteria->compare('a_phone',$this->a_phone,true);
		$criteria->compare('a_email',$this->a_email,true);
		$criteria->compare('a_adderss',$this->a_adderss,true);
		$criteria->compare('a_webset',$this->a_webset,true);
		$criteria->compare('a_isdel',$this->a_isdel);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Admin the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
